//
// Ephi - simulation of magnetic fields and particles
// Copyright (C) 2007 Indrek Mandre <indrek(at)mare.ee>
// For more information please see http://www.mare.ee/indrek/ephi/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "ephi.hpp"

// visualize magnetic field strength across a solenoid

#define RADIUS 0.1
#define DIST 0.05
#define ELEMENTS 5
#define CURRENT 5000
#define WIRE_RADIUS 0.008

int main (int argc, char *argv[])
{
  Statics statics;
  ElectroDynamics dyn(statics);

  make_solenoid (statics, ELEMENTS, RADIUS, WIRE_RADIUS, DIST, CURRENT);

  fprintf (stderr, "Calculating...\n");
  Screen screen(800, 800, 0.9, 0.9);
  Scene scene(dyn);
  scene.calc (screen);
  scene.render_map (screen);
  screen.write ("test6.bmp");
  printf ("OK: test6.bmp written, calculating the logarithmic image..\n");
  scene.set_coloring (20, true);
  scene.render_map (screen);
  screen.write ("test6_log.bmp");
  printf ("OK: test6_log.bmp written, now rendering field lines using LIC..\n");
  scene.set_coloring (1); // black&white
  scene.render_lic (screen);
  screen.write ("test6_lic.bmp");
  scene.set_coloring (0, true); // logarithmic, full colors
  scene.render_lic (screen);
  screen.write ("test6_lic_logcolor.bmp");
  printf ("OK: test6_lic.bmp written, we're done\n");

  return 0;
}

